package com.studyinsect.insect;

import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.log4j.BasicConfigurator;

import java.io.IOException;

/**
 * @Author: hanll
 * @ClassName: InsectTest
 * @Date: 2022-10-27 9:34
 * @Version: 1.0
 * @Description:
 */
public class InsectImage {

    public static void main(String[] args) throws IOException, CloneNotSupportedException {
        BasicConfigurator.configure();
        CloseableHttpClient httpClient = HttpClients.createDefault();
        HttpGet httpGet = new HttpGet("https://www.baidu.com/");
        httpClient.execute(httpGet);
        CloseableHttpResponse httpResponse = httpClient.execute(httpGet);
        if (httpResponse.getStatusLine().getStatusCode() == 200) {
            HttpEntity httpEntity = httpResponse.getEntity();
            String content = EntityUtils.toString(httpResponse.getEntity(), "UTF-8");
            System.out.println(content);
        }
        httpResponse.close();;
        httpGet.clone();
        httpClient.close();
    }
}
